import axios from 'axios'
import config from '../../../Mock/Li/config.js'

const state={
    zhu:[],//主数据（不动产）
    L_Config_List:[],//第一层弹框的数据
    L_Config_List_two:[],//第二层弹框的数据
}

const mutations={
    //配置页获取初始数据
    L_Config_Chu(state,data){   
        state.zhu=data
        state.L_Config_List=data
    },
    //新增
    L_Config_Zeng(state,data){
        alert('新增成功')
        state.L_Config_List_two.push(data)
    },
    //搜索
    L_Config_Sou(state,data){
        state.L_Config_List=state.zhu.filter(item=>{
            if(item.name.indexOf(data)>-1){
                return item
            }
        })
    }
}

const actions={
    //配置页获取初始数据
    async L_Config_chu({commit}){
        const lis=await axios.get("/ips/L_Configlist")
        commit("L_Config_Chu",lis.data.list)
    },
    //点击新增
    async L_Config_zeng({commit},data){
        // console.log("11111  ")
        commit("L_Config_Zeng",data)
    },
    //搜索
    async L_Config_sou({commit},data){
        commit("L_Config_Sou",data)
    }
}

export default {
    namespaced:true,
    state,
    actions,
    mutations
}






